<template>
	<view class="mydriverlist">
		<view class="mydriver_cell" v-for="item in list" :key="item.id" @click="openDriveInfo(item.id)">
			<view class="display_between">
				<view class="c-gray">试驾状态:</view>
				<view v-if="item.sign_status==0" class="c-red">未试驾</view>
				<view v-if="item.sign_status==1" class="c-green">已试驾</view>
				<view v-if="item.sign_status==2" class="c-gray">已取消</view>
			</view>
			<view class="display_between mt-5">
				<view class="c-gray">试驾车型:</view>
				<view class="flex-1 text-r">{{item.drive_car_series}}</view>
			</view>
			<view class="display_between mt-5" style="align-items: flex-start;">
				<view class="c-gray">试驾经销商:</view>
				<view class="flex-1 text-r">{{item.company_info}}</view>
			</view>
			<view class="display_between mt-5">
				<view class="c-gray">预约时间:</view>
				<view class="">{{item.create_time}}</view>
			</view>
			<view class="display_between mt-5" v-if="item.sign_status==1">
				<view class="c-gray">试驾时间:</view>
				<view class="">{{item.sign_time}}</view>
			</view>
			<view class="display_between mt-5" v-if="item.sign_status==2">
				<view class="c-gray">取消时间:</view>
				<view class="">{{item.sign_time}}</view>
			</view>
		</view>
		<view class=""></view>
		<view class=""></view>
	</view>
</template>

<script>
	import {
		getMyDriverList,
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				list: []
			};
		},
		onShow() {
			if (uni.getStorageSync('onload')) {
				this.getMyDriverList()
				uni.removeStorage({
					key: 'onload'
				})
			}
		},
		onLoad() {
			this.getMyDriverList()
		},
		methods: {
			getMyDriverList() {
				getMyDriverList({}).then(res => {
					if (res.state == 1) {
						this.list = res.data.list
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			openDriveInfo(id) {
				uni.navigateTo({
					url: '/pages/testdrive/testdriveresult?drive_id=' + id
				})
			}
		},
		onPullDownRefresh() {
			uni.stopPullDownRefresh()
			this.getMyDriverList()
		}
	}
</script>

<style lang="scss">
	.mydriverlist {
		padding: 30rpx;

		.mydriver_cell {
			font-size: 26rpx;
			padding: 30rpx;
			margin-bottom: 30rpx;
			border-radius: 8rpx;
			background-color: #f3f3f3;
		}
	}
</style>